Repository navigation
repo: Widestring cleanups - #5192
Open
Steven Malis (smalis-msft) wants to merge 2 commits into
Open
Steven Malis (smalis-msft) wants to merge 2 commits into
Steven Malis (smalis-msft) wants to merge 2 commits into
Conversation
Steven Malis (smalis-msft)
requested review from
Chris Oo (chris-oo)
and
a balanced review from Copilot
November 20, 2026 21:26
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The bounded RPC string conversion can cause undefined behavior through an out-of-bounds slice, while environment and KVP conversions accept trailing NULs, silently truncating values and allowing KVP key aliases.
3 open issues
What changed in this PR
This PR standardizes wide-string handling across OpenVMM’s Windows interfaces, firmware helpers, and tests, replacing manual encoding and NUL termination with widestring and existing UCS-2 types.
Changes:
- Replace manual wide-string buffers and literals with typed string helpers.
- Simplify UTF-16 conversions and add validation and encoding tests.
- Remove
wcharand update affected dependencies.
| File | Description |
|---|---|
| vmm_core/hyperv_dump/tests/cross_validate.rs | Use typed wide paths for DLL calls. |
| vmm_core/hyperv_dump/Cargo.toml | Add widestring for tests. |
| vm/whp/src/lib.rs | Convert PCI instance paths with U16CString. |
| vm/whp/Cargo.toml | Add Windows widestring dependency. |
| vm/loader/snp_bootshim/src/efi/tables.rs | Compare the complete firmware vendor string. |
| vm/devices/support/fs/lxutil/src/windows/util.rs | Use typed wide filesystem names. |
| vm/devices/support/fs/lxutil/src/windows/symlink.rs | Simplify trailing-NUL removal. |
| vm/devices/support/fs/lxutil/src/windows/readdir.rs | Convert directory names through U16Str. |
| vm/devices/support/fs/lxutil/src/windows/mod.rs | Simplify colon checks and wide-string test data. |
| vm/devices/storage/vhdx/tests/native_cross_validation.rs | Replace manual wide-path helper. |
| vm/devices/storage/vhdx/src/locator.rs | Decode UTF-16 without an intermediate vector. |
| vm/devices/storage/vhdx/Cargo.toml | Add Windows test dependency. |
| vm/devices/storage/disk_vhdmp/src/lib.rs | Centralize validated wide-path conversion. |
| vm/devices/storage/disk_vhdmp/Cargo.toml | Add widestring dependency. |
| vm/devices/net/netvsp/src/lib.rs | Use a compile-time wide friendly name. |
| vm/devices/net/netvsp/Cargo.toml | Add widestring dependency. |
| vm/devices/hyperv_ic/src/kvp.rs | Use typed NUL-terminated KVP strings. |
| vm/devices/hyperv_ic/src/kvp_tests.rs | Test string boundaries and malformed input. |
| vm/devices/hyperv_ic/Cargo.toml | Add widestring dependency. |
| vm/devices/get/test_igvm_agent_rpc_server/src/rpc/server.rs | Use static wide RPC identifiers. |
| vm/devices/get/test_igvm_agent_rpc_server/src/rpc/handlers.rs | Replace manual RPC string decoding. |
| vm/devices/get/test_igvm_agent_rpc_server/Cargo.toml | Add widestring dependency. |
| vm/devices/firmware/uefi_specs/src/uefi/nvram.rs | Clarify literal-generation documentation. |
| vm/devices/firmware/uefi_specs/src/lib.rs | Replace wchar literals with widestring. |
| vm/devices/firmware/uefi_specs/Cargo.toml | Switch optional wide-string dependency. |
| vm/devices/firmware/uefi_nvram_storage/src/in_memory.rs | Use UCS-2 types for test names. |
| vm/devices/firmware/uefi_nvram_storage/Cargo.toml | Remove wchar dependency. |
| vm/devices/firmware/hcl_compat_uefi_nvram_storage/src/lib.rs | Convert test names to UCS-2 types. |
| vm/devices/firmware/hcl_compat_uefi_nvram_storage/Cargo.toml | Remove wchar test dependency. |
| vm/devices/firmware/firmware_uefi/src/service/nvram/spec_services/mod.rs | Replace wide literals in NVRAM tests. |
| vm/devices/firmware/firmware_uefi/src/service/nvram/mod.rs | Use UCS-2 buffers in firmware tests. |
| vm/devices/firmware/firmware_uefi/Cargo.toml | Remove wchar test dependency. |
| support/ucs2/src/lib.rs | Simplify conversions and test encoding behavior. |
| support/pal/src/windows/security.rs | Simplify embedded-NUL test input. |
| support/pal/src/windows/process.rs | Use typed process strings and test environments. |
| support/pal/src/windows/fs/relative.rs | Use typed relative names and test surrogate preservation. |
| support/pal/src/windows.rs | Simplify Unicode conversion and extend tests. |
| support/hvs_file/src/writer.rs | Stream UTF-16LE encoding into output. |
| support/hvs_file/src/reader.rs | Remove intermediate UTF-16 decoding allocation. |
| support/crypto/src/x509/win.rs | Use typed certificate strings and attributes. |
| support/crypto/src/aes_kwp/win.rs | Borrow the terminated chaining-mode string. |
| support/crypto/src/aes_256_gcm/win.rs | Borrow the terminated chaining-mode string. |
| support/crypto/Cargo.toml | Add Windows widestring dependency. |
| petri/make_imc_hive/src/windows/offreg.rs | Use typed registry names and values. |
| petri/make_imc_hive/Cargo.toml | Add widestring dependency. |
| openhcl/underhill_attestation/src/jwt.rs | Simplify UTF-16 test-data construction. |
| Cargo.toml | Remove workspace wchar dependency. |
| Cargo.lock | Update dependencies and remove wchar packages. |
Review effort: Balanced
Steven Malis (smalis-msft)
enabled auto-merge (squash)
November 20, 2026 21:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Windows wide string requirements are annoying. Use our Ucs2 types and the widestring crate in more places, replacing manual handling and null fixups. Drop the wchr dependency completely, as it's redundant.